package com.atguigu.guli.service.vod.controller.admin;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.vod.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController

@RequestMapping("/admin/vod")
public class AdminVodController {
    @Autowired
    private VodService vodService ;

    //1.上传视频
    @PostMapping("upload")
    public R uploadVideo(MultipartFile file) {
        String videoId = vodService.uploadVideo(file) ;
        return R.ok().data("id",videoId) ;
    }

    //2.删除视频
    @DeleteMapping("delete/{videoId}")
    public R deleteVideo(@PathVariable String videoId) {
        vodService.deleteVideo(videoId) ;
        return R.ok() ;
    }

    //3.用户 获取视频播放凭证和播放地址
    @GetMapping("getPlayUrl/{videoId}")
    public R getPlayUrl(@PathVariable String videoId) {
        String playUrl = vodService.getPlayUrl(videoId) ;
        return R.ok().data("playUrl",playUrl) ;
    }
    @GetMapping("getPlayAuth/{videoId}")
    public R getPlayAuth(@PathVariable String videoId) {
        String getPlayAuth = vodService.getPlayAuth(videoId) ;
        return R.ok().data("getPlayAuth",getPlayAuth) ;
    }
}
